/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights
 * reserved. <a>http://www.cqcis.com</a>
 */
package com.cq.bd.dwr;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.cq.base.domain.Page;
import com.cq.bd.base.BaseDwr;
import com.cq.bd.domain.SWorker;
import com.cq.bd.domain.SWorkerFunction;
import com.cq.bd.domain.SWorkerRole;
import com.cq.bd.service.WorkerService;

/**
 * 工号、用户管理
 * 
 * @author huangmy
 * @date   2009-10-5
 */
public class WorkerDwr extends BaseDwr {
    private static final long serialVersionUID = 1L;
    private WorkerService workerService;
    
    /**
     * 创建员工
     * 
     * @param worker
     * @return
     */
    public void createWorker(SWorker worker) {
        worker.setLoginType(0);
        worker.setLoginNum(0);
        worker.setLastChgPwdTime(new Date());
        this.workerService.doCreateWorker(worker);
    }
    
    /**
     * 修改
     * 
     * @param worker
     */
    public void updateWorker(SWorker worker) {
        this.workerService.doUpdateWorker(worker);
    }
    
    /**
     * 工号设置无效
     * 
     * @param loginId
     */
    public void changeWorkerState(Long loginId, int state) {
        this.workerService.doChangeWorkerState(loginId, state);
    }
    
    /**
     * 获取工号
     * 
     * @param loginCode
     * @return
     */
    public List<SWorker> getWorkersByLoginCode(String loginCode) {
        return this.workerService.doGetWorkersByLoginCode(loginCode);
    }
    
    /**
     * 分页查找
     * 
     * @param filter
     * @param like
     * @param sort
     * @param pageNo
     * @param pageSize
     * @return
     */
    public Page pageWorkers(Map<String, String> filter, Map<String, String> like, Map<String, String> sort, int pageNo, int pageSize){
        return this.workerService.pageWorkers(filter, like, sort, pageNo, pageSize);
    }
    
    /**
     * 获取所有的员工
     * 
     * @return
     */
    public List<SWorker> getWorkers() {
        return this.workerService.doGetWorkers();
    }
    
    /**
     * 获取指定的员工
     * 
     * @param loginId
     * @return
     */
    public SWorker getWorker(Long loginId) {
        return this.workerService.doGetWorker(loginId);
    }
    
    /**
     * 获取指定的员工
     * 
     * @param loginId
     * @return
     */
    public List<SWorker> getWorkersByStaffId(Long staffId) {
        return this.workerService.doGetWorkersByStaffId(staffId);
    }
    
    /**
     * 工号与角色关联
     * 
     * @param workerRole
     */
    public void createWorkerRole(SWorkerRole workerRole) {
        this.workerService.doCreateWorkerRole(workerRole);
    }
    
    /**
     * 删除工号与角色关联
     * 
     * @param workerRole
     */
    public void removeWorkerRole(SWorkerRole workerRole) {
        this.workerService.doRemoveWorkerRole(workerRole);
    }
    
    /**
     * 工号权限加减
     * 
     * @param workerFunc
     */
    public void createWorkerFunc(SWorkerFunction workerFunc) {
        this.workerService.doCreateWorkerFunc(workerFunc);
    }
    
    /**
     * 修改工号权限加减
     * 
     * @param workerFunc
     */
    public void updateWorkerFunc(SWorkerFunction workerFunc) {
        this.workerService.doUpdateWorkerFunc(workerFunc);
    }
    
    /**
     * 删除工号权限加减
     * 
     * @param workerFunc
     */
    public void removeWorkerFunc(SWorkerFunction workerFunc) {
        this.workerService.doRemoveWorkerFunc(workerFunc);
    }

    public void setWorkerService(WorkerService workerService) {
        this.workerService = workerService;
    }
}
